#pragma once

#include "controlcenter_global.h"
#include <osg/ref_ptr>
#include "createdevicemanipulator.h"
#include "devicegroup.h"
#include "swinganimationeffect.h"
#include "transparentobjectroundeffect.h"

namespace osg
{
	class Camera;
}

namespace CoreBase
{
	class Drawable;
}

namespace ControlCenter
{
	class CONTROLCENTER_EXPORT InsertManipulator: public CreateDeviceManipulator
	{
	public:
		InsertManipulator(osg::Camera* maincamera);
		virtual void mouseClick(const osgGA::GUIEventAdapter* ea0,const osgGA::GUIEventAdapter* ea1,
			const osgGA::GUIEventAdapter* key0,const osgGA::GUIEventAdapter* key1);
		virtual void mouseRelease(const osgGA::GUIEventAdapter* ea0,const osgGA::GUIEventAdapter* ea1,
			const osgGA::GUIEventAdapter* key0,const osgGA::GUIEventAdapter* key1);
		virtual void mouseMove(const osgGA::GUIEventAdapter* ea0,const osgGA::GUIEventAdapter* ea1);
		virtual void mouseDoubleClick(const osgGA::GUIEventAdapter* ea0,const osgGA::GUIEventAdapter* ea1,
			const osgGA::GUIEventAdapter* key0,const osgGA::GUIEventAdapter* key1);
		virtual void mouseDrag(const osgGA::GUIEventAdapter* ea0,const osgGA::GUIEventAdapter* ea1,
			const osgGA::GUIEventAdapter* key0,const osgGA::GUIEventAdapter* key1);
		virtual void enableManipulator();
		virtual void disenableManipulator();
		struct DeviceTraverseMaskInfo
		{
			osg::ref_ptr<VrDataCore::DeviceActor>		_insertDev;
			int											_oldTraverseMask;
			int											_newTraverseMask;
			osg::ref_ptr<VrDataCore::SwingAnimationEffect>		_swingAnimationEffect;
		};
	protected:
		virtual ~InsertManipulator();
		bool testCreateObject();
		void clearInsertDeviceVector();
		void insertDeviceVector(CoreBase::ActorBase* dev);
		osg::ref_ptr<VrDataCore::SwingAnimationEffect> getOrCreateSwingAnimationEffect();
	private:
		VrDataCore::DeviceActor*								_createActor;
		VrDataCore::DeviceActor*								_editActor;
		DeviceTraverseMaskInfo									_parentActorStruct;
		osg::Vec3												_mouseCurrentpos;
		QVector<DeviceTraverseMaskInfo>							_insertVector;
		QVector<CoreBase::Drawable*>							_insertDrawableVector;
		QVector<osg::ref_ptr<VrDataCore::SwingAnimationEffect>>		_uniformMotionVector;
		osg::ref_ptr<VrDataCore::TransparentObjectRoundEffect>	_transparentObjectRoundEffect;
		int _distance;
		int _offsetxy;
		int _offsetxz;
	};
}